
#import "AppDelegate.h"
#import "NSString+UUID.h"
#import "TestImageBrowserItem.h"

@implementation AppDelegate


- (void)awakeFromNib {
	images = [[NSMutableArray array] retain];

}


- (void)dealloc {
	[images release];
	[super dealloc];
}


- (IBAction)addItems:(id)sender {
	int i;
	for (i = 0; i < ITEM_INCREMENT; i++) {
//		NSString *urlString = [NSString stringWithFormat:@"http://imagekit-test.googlecode.com/files/Core_Image_icon.png?dummy=%@", [NSString stringWithUUID]];
		NSString *urlString = [NSString stringWithFormat:@"http://localhost/PoweredByMacOSX.gif?dummy=%@", [NSString stringWithUUID]];
		NSURL *url = [NSURL URLWithString:urlString];
		id item = [[[TestImageBrowserItem alloc] initWithUrl:url] autorelease];
		[images addObject:item];
	}
	[imageBrowser reloadData];
}


- (IBAction)clearItems:(id)sender {
	[images removeAllObjects];
	[imageBrowser reloadData];
	[[NSGarbageCollector defaultCollector] collectExhaustively];
}



# pragma mark IKImageBrowserDataSource protocol methods

- (NSUInteger)numberOfItemsInImageBrowser:(IKImageBrowserView *)aBrowser {
	return [images count];
}

- (id)imageBrowser:(IKImageBrowserView *)aBrowser itemAtIndex:(NSUInteger)index {
	return [images objectAtIndex:index];
}






@end
